/**
 * EffectManager
 * @Author Ace.c
 * @Create 2016-12-05 16:00
 */
class EffectManager extends NotifyEvent {

    private scoreView: GameSceneScore;

    public constructor() {
        super();

        this.scoreView = new GameSceneScore();

        gameManager.i.addEventListener(EffectEvent.CleanAll, this.onCleanAll, this);
        gameManager.i.addEventListener(EffectEvent.ScoreTips, this.onScoreTips, this);
        gameManager.i.addEventListener(EffectEvent.CardRaise, this.onCardRaise, this);
        gameManager.i.addEventListener(EffectEvent.CardThrow, this.onCardThrow, this);
        gameManager.i.addEventListener(EffectEvent.CardThrowTips, this.onCardThrowTips, this);
    }

    private onScoreTips(scores: any) {
        this.scoreView.play(scores);
    }

    private onCleanAll() {
        GSController.i.gsView.updateState();
    }

    private onCardRaise(type: PopupType) {
        if (type != undefined) {
            CardRaiseEffect.play(type);
        }
        else {
            CardRaiseEffect.stop();
        }
    }

    private onCardThrow(arr: any[]) {
        if (arr && arr.length == 2) {
            ChupaiEffect.play(arr[0], arr[1]);
        }
        else {
            ChupaiEffect.stop(true);
        }
    }

    private onCardThrowTips(arr: any[]) {
        if (arr && arr.length == 2) {
            ChupaiTipsEffect.play(arr[1], (arr[0] == 1 || arr[0] == 3) ? 2 : 0);
        }
        else {
            ChupaiTipsEffect.stop();
        }
    }
}